package com.ruoyi.wxApp.domain;


import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 微信用户对象 dis_wxuser
 *
 * @author ruoyi
 * @date 2023-10-26
 */
public class DisWxuser {
    private static final long serialVersionUID = 1L;

    /**
     * 微信ID
     */
    private Integer wxId;

    /**
     * 微信openId
     */

    private String wxOpenid;

    /**
     * 微信昵称
     */

    private String wxNickname;

    /**
     * 头像地址
     */

    private String wxAvatarurl;


    /**
     * 删除标志（0代表存在 2代表删除）
     */

    private String delFlag;


    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public Integer getWxId() {
        return wxId;
    }

    public void setWxId(Integer wxId) {
        this.wxId = wxId;
    }

    public String getWxOpenid() {
        return wxOpenid;
    }

    public void setWxOpenid(String wxOpenid) {
        this.wxOpenid = wxOpenid;
    }

    public String getWxNickname() {
        return wxNickname;
    }

    public void setWxNickname(String wxNickname) {
        this.wxNickname = wxNickname;
    }

    public String getWxAvatarurl() {
        return wxAvatarurl;
    }

    public void setWxAvatarurl(String wxAvatarurl) {
        this.wxAvatarurl =wxAvatarurl;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("wxId", getWxId())
                .append("wxOpenid", getWxOpenid())
                .append("wxNickname", getWxNickname())
                .append("wxAvatarurl", getWxAvatarurl())
                .toString();
    }

    public void modifyWxAvatarurl() throws UnknownHostException {
        InetAddress localHost = InetAddress.getLocalHost();
        String hostAddress = localHost.getHostAddress();
        String baseUrl ="http://"+hostAddress+":8089";
        // 获取当前的 wxAvatarurl 并拼接新的基础 URL
        this.wxAvatarurl = baseUrl + getWxAvatarurl();
    }
    public void init(){
        this.wxId=0;
        this.delFlag="0";
        this.wxAvatarurl="";
        this.wxNickname="";
        this.wxOpenid="";

    }
}
